package org.jz.gae.redbook.spb.client.slate.district;

import org.jz.gae.redbook.spb.shared.DistrictEntityView;

import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.SimplePanel;
import com.google.gwt.user.client.ui.FlexTable;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.TextArea;
import com.google.gwt.user.client.ui.TextBox;
import com.google.gwt.user.client.ui.VerticalPanel;

public class DistrictPropertiesPanel extends Composite 
{
	  private final TextBox districtEngName = new TextBox();
	  private final TextBox districtRusName = new TextBox();
	  private final TextArea districtNote = new TextArea();
	  private final FlexTable detailsTable;
	  
	  public DistrictPropertiesPanel()
	  {
		  SimplePanel contentDetailsDecorator = new SimplePanel();
	    contentDetailsDecorator.setWidth("18em");
	    initWidget(contentDetailsDecorator);

	    VerticalPanel contentDetailsPanel = new VerticalPanel();
	    contentDetailsPanel.setWidth("100%");

	    // Create the contacts list
	    //
	    detailsTable = new FlexTable();
	    detailsTable.setCellSpacing(0);
	    detailsTable.setWidth("100%");
	    detailsTable.addStyleName("contacts-ListContainer");
	    detailsTable.getColumnFormatter().addStyleName(1, "add-contact-input");
	    initDetailsTable();
	    contentDetailsPanel.add(detailsTable);
	    
	    contentDetailsDecorator.add(contentDetailsPanel);
	  }
	  
	  private void initDetailsTable() {
	    detailsTable.setWidget(3, 0, new Label("Русское наименование:"));
	    detailsTable.setWidget(3, 1, districtRusName);
	    detailsTable.setWidget(2, 0, new Label("English name:"));
	    detailsTable.setWidget(2, 1, districtEngName);
	    detailsTable.setWidget(4, 0, new Label("Примечание:"));
	    detailsTable.setWidget(4, 1, districtNote);
	    districtRusName.setFocus(true);
	  }

	public DistrictEntityView pickUpInformation()
	{
		DistrictEntityView district = new DistrictEntityView();
		/**/
	    district.setDistrictEngName(districtEngName.getValue());
	    district.setDistrictRusName(districtRusName.getValue());
	    district.setDistrictNote(districtNote.getValue());
		return district;
	}

	}
